﻿using M.Warehouse.API.Application.Command.PickingCommand;
using M.Warehouse.Domain;
using M.Warehouse.Repository;
using M.Warehouse.Repository.WarehouseInterface;
//using M_Ingredient.Domain;
//using M_Ingredient.Repository.Interface;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace M.Warehouse.API.Application.CommandHandlers.PickingHandlers
{
    /// <summary>
    /// 添加生产领料
    /// </summary>
    public class PickingCreateCommandHandlers : IRequestHandler<PickingCreateCommand, int>
    {
        private readonly IPickingRepository _pickingRepository;
        //private readonly IIngredientRepository _ingredientRepository;
        private readonly WEFDbContext _db;
        /// <summary>
        /// 构造函数注入
        /// </summary>
        /// <param name="pickingRepository"></param>
        /// <param name="db"></param>
        /// <param name="ingredientRepository"></param>
        public PickingCreateCommandHandlers(IPickingRepository pickingRepository,WEFDbContext db/*,IIngredientRepository ingredientRepository*/)
        {
            _pickingRepository = pickingRepository;
            //_ingredientRepository = ingredientRepository;
            _db = db;
        }
        public async Task<int> Handle(PickingCreateCommand request, CancellationToken cancellationToken)
        {
            return await _pickingRepository.AddAsync(request);
        }
    }
}
